2 Problem: 11556 - Switch bulbs
3 Author: Andrés Mejía-Posada
4 (http://blogaritmo.factorcomun.org)
29 #define D(x) cout << #x " is " << x << endl
31 int d
[1<<15], suiche
[40];
40 scanf("%d %d", &n
, &m
);
42 for (int i
=0, k
, x
; i
<m
; ++i
){
47 suiche
[i
] |= (1 << x
);
51 for (int i
=0; i
<(1<<n
); ++i
) d
[i
] = INT_MAX
;
57 int u
= q
.front(); q
.pop();
58 for (int k
=0; k
<m
; ++k
){
59 int v
= u
^ suiche
[k
]; //Toggles lights
68 printf("Case %d:\n", caso
++);
70 scanf("%d", &queries
);
75 for (int i
=n
-1; i
>=0; --i
){
77 int bit
= buf
[i
] - '0';
78 destiny
|= (bit
<< (n
- i
- 1));
80 printf("%d\n", d
[destiny
] < INT_MAX
? d
[destiny
] : -1);